// Copyright 2010 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: tu@tulrich.com (Thatcher Ulrich)

// C++ translation of the WebGL benchmark code written in Javascript.
// Math utilities.

#ifndef GLMATH_H__
#define GLMATH_H__

float DotProduct(const float a[3], const float b[3]);
void CrossProduct(const float a[3], const float b[3], float out[3]);
void VectorNormalize(const float a[3], float out[3]);

void MakeOrientationAffine(const float origin[3], const float dir[3],
			   const float up[3], float model_mat[16]);
void AffineMatrixToGlMatrix(const float model_mat[16],
			    float model_mat_gl[16]);

// Return the inverse of the given affine matrix, assuming that
// the rotation part is normalized, by exploiting
// transpose==inverse for rotation matrix.
void InvertNormalized(const float m[16], float out[16]);

void MakeViewFromOrientation(const float orient[16],
			     float view[16]);
void MyGluPerspective(float fovy, float aspect, float z_near, float z_far,
                      float out[16]);
void MyMatrixMultiply(const float a[16], const float b[16], float out[16]);

#endif  // GLMATH_H__
